<?php

namespace app\models\search;

use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use app\models\AsrPlan;

/**
 * AsrPlanSearch represents the model behind the search form of `app\models\AsrPlan`.
 */
class AsrPlanSearch extends AsrPlan
{
    /**
     * @inheritdoc
     */
    public $belong;
    public function rules()
    {
        return [
            [['planname','created_at',], 'safe'],
//
        ];
    }

    /**
     * @inheritdoc
     */
    public function scenarios()
    {
        // bypass scenarios() implementation in the parent class
        return Model::scenarios();
    }

    /**
     * Creates data provider instance with search query applied
     *
     * @param array $params
     *
     * @return ActiveDataProvider
     */
    public function search($params)
    {
        $query = AsrPlan::find();
        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);
        $this->load($params);

        if (!$this->validate()) {
            // uncomment the following line if you do not want to return any records when validation fails
            // $query->where('0=1');
            return $dataProvider;
        }

        // grid filtering conditions
//        $query->andFilterWhere([
//        'plan_id' => $this->plan_id,
//        'create_at' => $this->create_at,
//        'already_call' => $this->already_call,
//        'line_num' => $this->line_num,
//        //'asr_mobile.listname'=>$this->listname,
//    ]);

        $query->andFilterWhere(['like', 'planname', $this->planname])
            ->andFilterWhere(['like', 'asr_audio.belong', $this->belong])
            ->andFilterWhere(['like', 'state', $this->state]);

        return $dataProvider;
    }
}
